home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / diskBoot.OpenProm / machMon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-24  |  8.5 KB  |  260 lines

  1. /*
  2.  * machMon.h --
  3.  *
  4.  *     Structures, constants and defines for access to the sun monitor.
  5.  *     These are translated from the sun monitor header file "openprom.h".
  6.  *
  7.  * Copyright (C) 1985 Regents of the University of California
  8.  * All rights reserved.
  9.  *
  10.  *
  11.  * $Header: /sprite/src/kernel/mach/sun4c.md/RCS/machMon.h,v 1.4 90/10/19 15:38:39 mgbaker Exp $ SPRITE (Berkeley)
  12.  */
  13.  
  14. #ifndef _MACHMON
  15. #define _MACHMON
  16.  
  17. /*
  18.  * The memory addresses for the PROM, and the EEPROM.
  19.  */
  20. #define EEPROM_BASE     0xffd04000
  21. #define PROM_BASE       0xffe8d4f0
  22.  
  23. /*
  24.  * The table entry that describes a device.  It exists in the PROM; a
  25.  * pointer to it is passed in MachMonBootParam.  It can be used to locate
  26.  * PROM subroutines for opening, reading, and writing the device.
  27.  *
  28.  * When using this interface, only one device can be open at once.
  29.  *
  30.  * NOTE: I am not sure what arguments boot, open, close, and strategy take.
  31.  * What is here is just translated verbatim from the sun monitor code.  We
  32.  * should figure this out eventually if we need it.
  33.  */
  34.  
  35. typedef struct {
  36.     char    devName[2];        /* The name of the device */
  37.     int    (*probe)();        /* probe() --> -1 or found controller
  38.                        number */
  39.     int    (*boot)();        /* boot(bp) --> -1 or start address */
  40.     int    (*open)();        /* open(iobp) --> -1 or 0 */
  41.     int    (*close)();        /* close(iobp) --> -1 or 0 */
  42.     int    (*strategy)();        /* strategy(iobp,rw) --> -1 or 0 */
  43.     char    *desc;            /* Printable string describing dev */
  44.     /* Sun4 has struct devinfo here.  Do I need it? */
  45. } MachMonBootTable;
  46.  
  47. /*
  48.  * Structure set up by the boot command to pass arguments to the program that
  49.  * is booted.
  50.  */
  51.  
  52. typedef struct {
  53.     char        *argPtr[8];    /* String arguments */
  54.     char        strings[100];    /* String table for string arguments */
  55.     char        devName[2];    /* Device name */
  56.     int        ctlrNum;    /* Controller number */
  57.     int        unitNum;    /* Unit number */
  58.     int        partNum;    /* Partition/file number */
  59.     char        *fileName;    /* File name, points into strings */
  60.     MachMonBootTable   *bootTable;    /* Points to table entry for device */
  61. } MachMonBootParam;
  62.  
  63. /*
  64.  * Memory layout stuff for the sun4c prom.
  65.  */
  66. typedef    struct    Mach_MemList {
  67.     struct        Mach_MemList    *next;
  68.     unsigned int    address;
  69.     unsigned int    size;
  70. } Mach_MemList;
  71.  
  72. typedef unsigned int MachMonIhandle;
  73. typedef unsigned int MachMonPhandle;
  74.  
  75. struct    config_ops {
  76.         int (*devr_next)(/* int nodeid */);
  77.         int (*devr_child)(/* int nodeid */);
  78.         int (*devr_getproplen)(/* int nodeid; caddr_t name; */);
  79.         int (*devr_getprop)(/* int nodeid; caddr_t name; addr_t value; */);
  80.         int (*devr_setprop)(/* int nodeid; caddr_t name; addr_t value; int len;
  81. */);
  82.         int (*devr_nextprop)(/* int nodeid; caddr_t previous; */);
  83. };
  84.  
  85. #define    MACHMON_MAGIC    0x10010407
  86. /*
  87.  * Here is the structure of the vector table which is at the front of the boot
  88.  * rom.  The functions defined in here are explained below. Fields marked
  89.  * with O1 are only valid with prom v_romvec_version less than 2.
  90.  * 
  91.  */
  92.  
  93. typedef struct {
  94.     unsigned int    v_magic;      /* magic mushroom. Should be
  95.                        * MACHMON_MAGIC. */
  96.     unsigned int          v_romvec_version; /* Version number of "romvec" */
  97.     unsigned int    v_plugin_version; /* Plugin Architecture version */
  98.     unsigned int    monId;          /* version # of monitor firmware */
  99.     Mach_MemList    **physMemory;      /* O1 total physical memory list */
  100.     Mach_MemList    **virtMemory;      /* O1 taken virtual memory list */
  101.     Mach_MemList    **availMemory;    /* O1 available physical memory */
  102.     struct config_ops    *v_config_ops;      /* dev_info configuration access */
  103.     /*
  104.      * storage device access facilities
  105.      */
  106.     char        **v_bootcommand;  /* expanded with PROM defaults */
  107.     unsigned int    (*v_open)(/* char *name */);
  108.     unsigned int    (*v_close)(/* unsigned int fileid */); 
  109.     /*
  110.      * block-oriented device access
  111.      */
  112.     unsigned int    (*v_read_blocks)();    /* O1 */
  113.     unsigned int    (*v_write_blocks)();     /* O1 */
  114.     /*
  115.      * network device access
  116.      */
  117.     unsigned int    (*v_xmit_packet)();     /* O1 */
  118.     unsigned int    (*v_poll_packet)();     /* O1 */
  119.     /*
  120.      * byte-oriented device access
  121.      */
  122.     unsigned int    (*v_read_bytes)();     /* O1 */
  123.     unsigned int    (*v_write_bytes)();     /* O1 */
  124.  
  125.     /*
  126.      * 'File' access - i.e.,  Tapes for byte devices.  TFTP for network devices
  127.      */
  128.     unsigned int     (*v_seek)();
  129.     /*
  130.      * single character I/O
  131.      */
  132.     unsigned char    *inSource;       /* Current source of input */
  133.     unsigned char    *outSink;        /* Currrent output sink */
  134.     unsigned char    (*getChar)();    /* Get a character from input */ 
  135.     void        (*putChar)();    /* Put a character to output sink. */
  136.     int            (*mayGet)();     /* Maybe get a character, or "-1". */
  137.     int            (*mayPut)();     /* Maybe put a character, or "-1". */
  138.     /* 
  139.      * Frame buffer
  140.      */
  141.     void        (*fbWriteStr)();  /* write a string to framebuffer */
  142.     /*
  143.      * Miscellaneous Goodies
  144.      */
  145.     void        (*reBoot)();       /* reboot machine */
  146.     int            (*printf)();       /* handles fmt string plus 5 args */
  147.     void        (*abortEntry)();   /* Entry for keyboard abort. */
  148.     int         *nmiClock;       /* Counts in milliseconds. */
  149.     void        (*exitToMon)();/* Exit from user program. */
  150.     void        (**v_vector_cmd)();/* Handler for the vector */
  151.     void        (*v_interpret)();  /* interpret forth string */
  152.     MachMonBootParam    **bootParam;    /* O1 - boot parameters. */
  153.  
  154.     unsigned int    (*v_mac_address)(/* int fd; caddr_t buf */);
  155.                         /* Copyout ether address */
  156.     char    **bootpath;        /* Full path name of boot device */
  157.     char    **bootargs;        /* Boot cmd line after dev spec */
  158.  
  159.     MachMonIhandle *op_stdin;        /* Console input device */
  160.     MachMonIhandle *op_stdout;        /*  Console output device */
  161.  
  162.     MachMonPhandle (*op_phandle)(/* MachMonIhandle ihandle */);
  163.                     /* V2: Convert ihandle to phandle */
  164.  
  165.     char *    (*op_alloc)(/* caddr_t virthint, u_int size */);
  166.                     /* V2: Allocate physical memory */
  167.  
  168.     void    (*op_free)(/* caddr_t virt, u_int size */);
  169.                     /* V2: Deallocate physical memory */
  170.  
  171.     char *    (*op_map)(/* caddr_t virthint, u_int space, u_int phys,
  172.         u_int size */);    /* V2: Create device mapping */
  173.  
  174.     void    (*op_unmap)(/* caddr_t virt, u_int size */);
  175.                     /* V2: Destroy device mapping */
  176.  
  177.     MachMonIhandle (*op_open)(/* char *name */);
  178.     int    (*op_close)(/* MachMonIhandle fileid */);
  179.     int    (*op_read)(/* MachMonIhandle fileid, caddr_t buf, u_int len */);
  180.     int    (*op_write)(/* MachMonIhandle fileid, caddr_t buf, u_int len */);
  181.     int    (*op_seek)(/* MachMonIhandle fileid, u_int offsh, u_int offsl */);
  182.     void    (*op_chain)(/* caddr_t virt, u_int size, caddr_t entry,
  183.         caddr_t argaddr, u_int arglen */);
  184.     void    (*op_release)(/* caddr_t virt, u_int size */);
  185.     int            *v_reserved[15];
  186.     /*
  187.      * Beginning of machine-dependent portion.
  188.      */
  189.     void        (*SetSegInContext)();    /* set seg map in another
  190.                          * context without worrying
  191.                          * about whether it's mapped. */
  192. } MachMonRomVector;
  193.  
  194. /*
  195.  * Functions defined in the vector:
  196.  *
  197.  *
  198.  * getChar -- Return the next character from the input source
  199.  *
  200.  *     unsigned char getChar()
  201.  *
  202.  * putChar -- Write the given character to the output source.
  203.  *
  204.  *     void putChar(ch)
  205.  *       char ch;
  206.  *
  207.  * mayGet -- Maybe get a character from the current input source.  Return -1
  208.  *           if don't return a character.
  209.  *
  210.  *     int mayGet()
  211.  *
  212.  * mayPut -- Maybe put a character to the current output source.   Return -1
  213.  *           if no character output.
  214.  *
  215.  *    int  mayPut(ch)
  216.  *        char ch;
  217.  *
  218.  * fbWriteStr -- Write a string to the frame buffer.
  219.  *
  220.  *       void fwritestr(addr,len)
  221.  *          register unsigned char *addr;    / * String to be written * /
  222.  *          register short len;            / * Length of string * /
  223.  *
  224.  * printf -- Scaled down version of C library printf.  Only %d, %x, %s, and %c
  225.  *          are recognized.
  226.  *
  227.  * abortEntry -- Entry for keyboard abort.
  228.  *
  229.  *     void abortEntry()
  230.  *
  231.  * SetSegInContext(c, v, p)
  232.  *    context        c;
  233.  *    virtual addr    v;
  234.  *    pmeg_num    p;
  235.  */
  236.  
  237. /*
  238.  * For accessing the romVector.
  239.  */
  240. extern MachMonRomVector *romVectorPtr;
  241.  
  242. /*
  243.  * Functions and defines to access the monitor.
  244.  */
  245.  
  246. #define Mach_MonPrintf (romVectorPtr->printf)
  247. #define Mach_MonGetChar (romVectorPtr->getChar)
  248.  
  249. extern    void     Mach_MonPutChar _ARGS_((int ch));
  250. extern    int      Mach_MonMayPut _ARGS_((int ch));
  251. extern    void    Mach_MonAbort _ARGS_((void));
  252. extern    void    Mach_MonReboot _ARGS_((char *rebootString));
  253. extern  void    Mach_MonTrap _ARGS_((Address address_to_trap_to));
  254. extern    void    Mach_MonStopNmi _ARGS_((void));
  255. extern    void    Mach_MonStartNmi _ARGS_((void));
  256.  
  257. extern int    Mach_MonSearchProm _ARGS_((char *name, char *attr, char *buf,                        int buflen));
  258.  
  259. #endif /* _MACHMON */
  260.